package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TworkerDao;
import com.xy.manage.model.Tworker;
import com.xy.manage.service.TworkerService;

@Service
@Transactional
public class TworkerServiceImpl extends BaseServiceImpl<Tworker> implements
		TworkerService {
	private TworkerDao tworkerDao;

	public TworkerServiceImpl(TworkerDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tworkerDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tworkerDao.checkExist("Tworker", paraName, paraValue);
	}

	@Override
	public List<Tworker> getTworker(Map<String, Object> map) {
		return tworkerDao.getTworker(map);
	}
	@Override
	public Pagination getTworkerByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tworkerDao.getTworkerByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tworker save(Tworker tworker) {
	//	tworker.setModtime(new Date());
		if(tworker.getWorkid()==null){
			//新增
        	return super.save(tworker);
		}else{
			//更新
			Tworker tworker1=tworkerDao.get(tworker.getWorkid());
			try {
				BeanUtil.copyNotNullProperties(tworker1, tworker);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tworker1);
		}
	}
}